package com.pig4cloud.pigx.wallet.controller;


import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.file.core.FileTemplate;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import com.pig4cloud.pigx.wallet.entity.ImputationRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/oss" )
@Api(value = "oss", tags = "上传图片")
public class OssController {

	private final FileTemplate template;

	/**
	 * 图片上传
	 */
//	@Inner(value = false)
	@ApiOperation(value = "图片上传", notes = "图片上传")
	@PostMapping("/upload")
	public R upload(@RequestPart MultipartFile file) throws Exception {

		template.putObject("rooexchanges", file.getOriginalFilename(), file.getInputStream());

		return R.ok("https://rooexchanges.oss-cn-chengdu.aliyuncs.com/"+file.getOriginalFilename());
	}
}
